<?php
namespace app\admin\controller;

use think\Controller;
use think\Session;
use think\Db;

class Base extends Controller
{
    /*
     * 析构函数
     */
    public function __construct()
    {
        Session::Start();
        header("Cache-control: private");
        parent::__construct();
    }

    /*
     * 初始化操作
     */
    public function _initialize(){
        $this->request->isAjax() ? define('IS_AJAX',true) : define('IS_AJAX',false);  //是否ajax提交
        ($this->request->method() == 'GET') ? define('IS_GET',true) : define('IS_GET',false);  // 是否get提交
        ($this->request->method() == 'POST') ? define('IS_POST',true) : define('IS_POST',false);  //post提交

        define('MODULE_NAME',$this->request->module());  // 当前模块名称是
        define('CONTROLLER_NAME',$this->request->controller()); // 当前控制器名称
        define('ACTION_NAME',$this->request->action()); // 当前操作名称是
        define('PREFIX',C('database.prefix')); // 数据库表前缀

        $actionName = strtolower(ACTION_NAME);
        if (in_array($actionName, array('login','verify','loginout'))){
        }else{
            if (session('admin_id') > 0) {
            } else {
                $this->error('请登录！', U('Admin/Admin/login'), 1);
            }
        }
        $initMenu = Db::name('menu')->where(array("is_show" => 1))->order('list_order asc, menu_id desc')
                                    ->cache('menu',3600)
                                    ->select();
        $this->assign('initMenu', $initMenu);//菜单选项
    }

}